package com.sky.mapper;

import com.sky.entity.VueFormFieldConfig;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface VueFormFieldConfigMapper {
    @Insert("INSERT INTO form_field_config (template_id, field_name, field_label, field_type, required, " +
           "sort_order, material_category, field_group, material_type, field_options) " +
           "VALUES (#{templateId}, #{fieldName}, #{fieldLabel}, #{fieldType}, #{required}, " +
           "#{sortOrder}, #{materialCategory}, #{fieldGroup}, #{materialType}, " +
           "#{fieldOptions,jdbcType=VARCHAR,typeHandler=com.sky.handler.ListTypeHandler})")
    void insertFormFieldConfig(VueFormFieldConfig fieldConfig);

    @Select("SELECT * FROM form_field_config WHERE template_id = #{templateId}")
    List<VueFormFieldConfig> getFieldsByTemplateId(Long templateId);

    @Delete("DELETE FROM form_field_config WHERE template_id = #{templateId}")
    void deleteByTemplateId(Long templateId);
}